package com.ww.springboot.boot.thread.study.executor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

/**
 * 线程池1
 *
 * @author wanwei
 * @since 2021-04-20 11:03
 */
public class ExecutorDemo1 {

    public static void main(String[] args) throws InterruptedException {
        ExecutorService executorService = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
        for (int i = 0; i < 100000; i++) {
            executorService.execute(new ThreadDemo());
        }
        executorService.shutdown();
        //executorService.shutdownNow();
        while (!executorService.isTerminated()) {
            TimeUnit.SECONDS.sleep(1);
        }
        System.out.println("总数：" + ThreadDemo.total);
    }
}
